{% extends '@YesknMain/base.html.twig' %}

{% block main %}
    <div class="row">
        <div class="col-md-12">
            <div class="login-panel panel panel-default">
                <div class="panel-heading">
                    {{ 'login'|trans }} {{ 'site_name'|trans }}
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-md-3"></div>
                        <div class="col-md-6">
                            {% if error %}
                                <div class="alert alert-danger alert-dismissable">
                                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                    {{ error.message|trans(error.messageData, 'security') }}
                                </div>
                            {% endif %}

                            {% include 'flash_messages.html.twig' %}

                            <form data-pjax id="loginForm" action="{{ path('do_login') }}" method="post" role="form">
                                <fieldset>
                                    <div class="form-group">
                                        <input type="text" class="form-control" placeholder="{{ '用户名'|trans }} or {{ '邮箱'|trans }}" id="username"
                                               name="_username" value="{{ last_username }}" autofocus>
                                    </div>
                                    <div class="form-group">
                                        <input class="form-control" placeholder="{{ '密码'|trans }}" type="password" id="password"
                                               name="_password" value="">
                                    </div>
                                    <div class="checkbox">
                                        <label>
                                            <input checked id="remember_me" name="_remember_me" type="checkbox"> 记住登录状态
                                        </label>
                                    </div>
                                    <input type="hidden" name="_target_path" value="/admin"/>
                                    <!-- Change this to a button or input when using this as a form -->
                                    <button type="submit" class="btn btn-lg btn-success btn-block">{{ 'login'|trans }}</button>
                                </fieldset>
                            </form>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // $(document).onPjax('submit', '#loginForm', function (event) {
        //     event.preventDefault();
        //     $.pjax.submit(event, 'body', {
        //         fragment: 'body',
        //         timeout: 6000
        //     })
        // })
    </script>
{% endblock %}

{% block sidebar %}
    {% include '@YesknMain/sidebar-login.html.twig' %}
{% endblock %}
